﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ServiceRepository.DataModel.Mapping
{
    public abstract class BaseMapper<T,K>
    {
        protected ServiceRepositoryDataContext _ctx;

        protected BaseMapper()
        {
            throw new NotImplementedException();
        }

        public BaseMapper(ServiceRepositoryDataContext ctx)
        {
            _ctx = ctx;
        }
        /// <summary>
        /// Obtains the matching entity in de data model for the specied domain model entity
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        protected virtual T FromDomain(K model)
        {
            return default(T);
        }

        /// <summary>
        /// Obtains the matching entity in de domain model for the specied data model entity
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        protected virtual K FromData(T data)
        {
            return default(K);
        }

        /// <summary>
        /// Flushes changes to the database
        /// </summary>
        public void SaveChanges()
        {
            _ctx.SubmitChanges();
        }
    }
}
